package com.loanapp.server.market.api.bbs.api;


import com.github.pagehelper.PageInfo;
import com.loanapp.server.market.api.bbs.entity.Post;
import com.loanapp.server.market.api.bbs.hystrix.PostApiFallbackFactory;
import com.loanapp.server.market.api.bbs.query.PostQuery;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@FeignClient(value = "loanapp-server-market-provider",path =PostApi.mapping,fallbackFactory = PostApiFallbackFactory.class)
public interface PostApi {

    static String mapping="post";

    /**
     * 获取帖子列表（带评论条数）
     * @return
     */

    @RequestMapping(value ="getPostListPage",method = RequestMethod.POST)
    public PageInfo<Map<String,Object>> getPostListPage(@RequestBody PostQuery query) throws Exception;

    /**
     * 通过id获取帖子（带评3论条数）
     * @return
     */
    @RequestMapping(value ="getPostWithCommentById",method = RequestMethod.POST)
    public Map<String,Object> getPostWithCommentById(@RequestParam(value = "id") Long id) throws Exception;


    @RequestMapping(value ="Insert",method = RequestMethod.POST)
    public Long Insert(@RequestBody Post post) throws  Exception;

    @RequestMapping(value ="CanPost",method = RequestMethod.POST)
    public boolean CanPost(@RequestParam("id") Long uid) throws  Exception;
}
